1. Field of the Invention
The invention relates to flash memories, and more particularly to accessing flash memories.
2. Description of the Related Art
A flash memory is a non-volatile memory that can be electrically erased and reprogrammed. Flash memories are primarily used in memory cards and USB flash drives for general storage. Flash memory costs far less than EEPROM and therefore has become a dominant memory device. Examples of electronic device applications include Personal Digital Assistants (PDA) and laptop computers, digital audio players, digital cameras, and mobile phones.
A flash memory comprises a large number of memory units, and each memory unit, has a physical address. Data recorded in memory units of a flash memory is accessed according to the physical addresses of the memory units. When a host wants to access data stored in a flash memory, the host, however, accesses the data according to logical addresses of the data. Because the logical addresses are not identical to the physical addresses, a data storage device comprising the flash memory must first convert the logical addresses sent from the host to physical addresses, and then access data stored in the flash memory according to the physical addresses.
Generally, a data storage device records a mapping relationship between logical addresses and physical addresses of a flash memory in an address link table as the basis for conversion of the logical addresses to the physical addresses. The address link table is built when the flash memory is initialized. Each physical address of the flash memory therefore has a corresponding logical address mapped thereto according to the address link table.
The conventional data storage device, however, has some disadvantages. First, because each physical address of the flash memory has a corresponding logical address mapped thereto, each host access of a logical address leads to a physical access of a memory unit, with a physical address to which the logical address will be mapped. A great number of memory units of the flash memory, however, store no data. When a host wants to access a logical address mapped to a memory unit storing no data, the memory access generates no meaningful results, merely consumes system resources and causes system delay.
In addition, because each physical address of the flash memory has a corresponding logical address mapped thereto, the host can access all memory units of the flash memory. In addition to the flash memory, the data storage device also comprises a controller. Because all memory units of the flash memory can be accessed by the host, when the controller requires storing data, the controller cannot use empty memory units of the flash memory for data storage, resulting in a waste of system resources. Thus, a method for accessing a flash memory is required.